﻿using System;
using System.Collections.Generic;
using System.Text;
using FeedDotNet.Common;

namespace ConsoleApplication
{
    class NZBIndexParser
    {
        public static Feed CreateFeedWithNzbs(Feed feed)
        {
            List<IFeedProvider> providers = new List<IFeedProvider>();
            foreach (FeedItem item in feed.Items)
            {
                providers.Add(new NzbIndexProvider(item, item.Title, "", "2000"));
            }

            FeedFetcher fetcher = new FeedFetcher(providers);
            fetcher.FetchFeeds();

            Feed newFeedWithNzbs = new Feed();

            foreach (IFeedProvider provider in providers)
            {
                Feed nzbFeed = provider.FullFeed;
                newFeedWithNzbs.Items.Add(((NzbIndexProvider)provider).PopulateItemWithNzbLink(nzbFeed));
            }

            return newFeedWithNzbs;
        }
    }
}
